package com.example.pathprotectsystem.mapper;

import com.example.pathprotectsystem.pojo.Path;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PathMapper {
    @Insert("insert into path(id, pathName, pavementType, startAddress, endAddress, pathType, designUnit, belong, longth, velocity, level1)" +
            "values(#{id}, #{pathName}, #{pavementType}, #{startAddress}, #{endAddress}, #{pathType}, #{designUnit}, #{belong}, #{longth}, #{velocity}, #{level1})")
    void addpath(Path path);

    List<Path> pathlist(String str);

    @Update("update path set pathName = #{pathName}, pavementType = #{pavementType}, startAddress = #{startAddress}, endAddress = #{endAddress}, " +
            "pathType = #{pathType}, designUnit = #{designUnit}, belong = #{belong}, longth = #{longth}, velocity = #{velocity}, level1 = #{level1} where id = #{id}")
    void pathupdate(Path path);

    @Delete("delete from path where id=#{id}")
    void pathdelete(int id);

    @Select("select pathName from path")
    List<String> getpaths();

    @Select("select id from path where pathName=#{pathName}")
    int findPathIdByPathName(String pathName);

    @Select("select pavementType from path where id = #{pathId}")
    String getpavementType(int pathId);

    @Select("select pathName from path")
    List<String> pathall();

    @Select("select * from path where pathName = #{pathName}")
    Path findPathByName(String pathName);

    @Select("select count(*) from path where pathName = #{name}")
    int findPathByPathName(String name);
    @Select("select pavementType from path where pathName = #{pathName}")
    String getpavementTypeBypathName(String pathName);
    @Select("select * from path")
    List<Path> getallpath();
}
